package nl.saxion.security.synchronize;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;

import java.security.NoSuchAlgorithmException;

import nl.saxion.security.encryption.TransformerAES;

/**
 * Class new file object used for synchronization
 *
 * @author EII7SCb
 *
 */
public class FileIncHash extends File implements Serializable{
	

	private static final long serialVersionUID = -3718583488677721134L;
	private String encryptedHash;
	private String decryptedHash;
	private long lastModiDate = 0;
	private boolean del = false;
	
	/**
	 * Create File
	 * @param path
	 * @throws NoSuchAlgorithmException
	 * @throws IOException
	 */
	public FileIncHash(String path) throws NoSuchAlgorithmException, IOException{
		super(path);
		
		if(!super.isDirectory() && super.exists()){
			lastModiDate = super.lastModified();		
		}
	}
	
	
	public void setLastModifiedDate(Long date)
	{
		lastModiDate = date;
	}
	
	public long getLastModifiedDate()
	{
		return lastModiDate;
	}
	
	public String getEncryptedHash(){
		return encryptedHash;
	}
	
	public String getDecryptedHash(){
		return decryptedHash;
	}
	
	
	public void setEncryptedHash(String hash)
	{
		encryptedHash = hash;
	}
	
	public void setDecryptedHash(String hash)
	{
		 decryptedHash = hash;
	}
	
	public long getLastModiDate()
	{
		return lastModiDate;
	}
	
	public boolean isDelete()
	{
		return del;
	}
	
	public void setDel(boolean isDel)
	{
		del = isDel;
	}
	
	/**
	 * Compare FileInchHahs with file based on name
	 * @param file
	 * @return is filenames match
	 */
	public boolean compareFileNames(File file)
	{
		if(getName().equals(file.getName()))
			return true;
		else
			return false;
	}
	

	public void renameTo(String string) {
		super.renameTo(new File(string) );
		
	}
}
